import hashlib

# 经典的哈希算法 - MD5 / SHA1 / SHA256 / SHA512
# 单向哈希函数 ---> 数字签名/指纹 ---> 防伪造防篡改
hasher = hashlib.md5()
with open('Python-3.8.0.tar.xz', 'rb') as file:
    for data in iter(lambda: file.read(2048), b''):
        hasher.update(data)
    # data = file.read(2048)
    # while data:
    #     hasher.update(data)
    #     data = file.read(2048)
print(hasher.hexdigest())
